// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sys

import (
	"context"
	"hotgo/api/admin/opsbanners"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	OpsBanners = cOpsBanners{}
)

type cOpsBanners struct{}

// List 查看广告运营列表
func (c *cOpsBanners) List(ctx context.Context, req *opsbanners.ListReq) (res *opsbanners.ListRes, err error) {
	list, totalCount, err := service.SysOpsBanners().List(ctx, &req.OpsBannersListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.OpsBannersListModel{}
	}

	res = new(opsbanners.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Edit 更新广告运营
func (c *cOpsBanners) Edit(ctx context.Context, req *opsbanners.EditReq) (res *opsbanners.EditRes, err error) {
	err = service.SysOpsBanners().Edit(ctx, &req.OpsBannersEditInp)
	return
}

// View 获取指定广告运营信息
func (c *cOpsBanners) View(ctx context.Context, req *opsbanners.ViewReq) (res *opsbanners.ViewRes, err error) {
	data, err := service.SysOpsBanners().View(ctx, &req.OpsBannersViewInp)
	if err != nil {
		return
	}

	res = new(opsbanners.ViewRes)
	res.OpsBannersViewModel = data
	return
}

// Status 更新广告运营状态
func (c *cOpsBanners) Status(ctx context.Context, req *opsbanners.StatusReq) (res *opsbanners.StatusRes, err error) {
	err = service.SysOpsBanners().Status(ctx, &req.OpsBannersStatusInp)
	return
}
